<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>消息中心</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/utilCss.css">
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery.js"></script>
    <style>

    </style>
</head>

<body>
    <header class="lxb_div_head">
        <div class="mian">
            <div class="lxb_div_head_letf">
            </div>
            <div class="lxb_div_head_text">
                消息中心
            </div>
            <div class="lxb_div_head_rigth"></div>
        </div>
    </header>
</body>

<script type="text/javascript">
    //手机系统版本，用以区分Android和ios，以执行不同api
    var phoneSystem;

    apiready = function() {
        phoneSystem = api.systemType;
        $('.lxb_div_head_letf').click(function() {
            closeWinDb();
        });

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            closeWinDb();
        });
        getInitDatas();
        openFm('newsList_fram', './newsList_fram.html', null);
    }

    //关闭数据库
    function closeWinDb() {
        api.sendEvent({
            name: 'newsListBack',
            extra: {
                key1: 'value1',
            }
        });

    }

    /**
     * 打开frame
     * @param{String} name - frame名
     * @param{String} url - frame的相对路径
     * @param{Number} type - frame的类型;0==已审核;1==未审核;
     */
    function openFm(name, url, msg) {
        var frameheigh = getFrameY();
        console.log('...........' + frameheigh);
        api.openFrame({
            name: name,
            url: url,
            rect: {
                x: 0,
                y: frameheigh,
                w: api.winWidth,
                h: 'auto'
            },
            pageParam: {
                'h': $api.dom('header').offsetHeight,
                'msg': msg
            }
        });
    }

    function getFrameY(){
      var frameheigh = $api.dom('header').offsetHeight;
      var systemType = api.systemType;
      if(api.systemType === 'ios'){
          var systemVersion = api.systemVersion;
          if(parseFloat(systemVersion) >= 11.0){
            frameheigh = frameheigh + 20;
          }
          return frameheigh;
      }
      return frameheigh;
    }

    //获取app 传过来的数据
    function getInitDatas() {
        var appdat1;
        if ('android' === phoneSystem) {
            appdat1 = api.appParam;
            appdat1 = JSON.parse(appdat1);
        } else if ('ios' === phoneSystem) {
            appdat1 = api.pageParam;
        }

        var jsonData = appdat1.pushjson;
        var userid = appdat1.userid + '';
        console.log('.........jsonData......' + jsonData);
        console.log('.........userid......' + userid);
        $api.setStorage('appJsonData', jsonData);
        $api.setStorage('altairUserid', userid);
    }

    //判断obj是否为json对象
    function isJson(obj) {
        var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length;
        return isjson;
    }
</script>

</html>
